using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using RMSM;

namespace AC.Report
{
	public partial class QuayPhim : DevExpress.XtraReports.UI.XtraReport
	{
		private LanQuayPhimBOCollection lanQuayPhimBOCollection = null;

		public QuayPhim(string title, int HopDongID, CTQuayPhimBOCollection chiTietQuayPhimBOCollection, LanQuayPhimBOCollection lanQuayPhimBOCollection)
		{
			InitializeComponent();

			if (title == null)
				this.ReportHeader.Visible = false;
			else
				this.lblTitle.Text = title;

			if (lanQuayPhimBOCollection == null)
				this.lanQuayPhimBOCollection = LanQuayPhimBOCollection.GetLanQuayPhimBOCollection("HOPDONGID=" + HopDongID, "LANQUAYPHIMID");
			else
				this.lanQuayPhimBOCollection = lanQuayPhimBOCollection;

			this.lblGhiChu.SummaryGetResult += new SummaryGetResultHandler(lblGhiChu_SummaryGetResult);
			this.lblNgayQuay.SummaryGetResult += new SummaryGetResultHandler(lblNgayQuay_SummaryGetResult);
			this.lblNgayGiao.SummaryGetResult += new SummaryGetResultHandler(lblNgayGiao_SummaryGetResult);


			this.bds.DataSource = chiTietQuayPhimBOCollection;
		}

		private void lblGhiChu_SummaryGetResult(object sender, SummaryGetResultEventArgs e)
		{
			int LanQuayPhimID = (int)GetCurrentColumnValue("LanQuayPhimID");
			LanQuayPhimBO lanQuayPhimBO = this.lanQuayPhimBOCollection.GetBO(LanQuayPhimID);
			e.Result = (string.IsNullOrEmpty(lanQuayPhimBO.GhiChu) ? "" : lanQuayPhimBO.GhiChu);
			e.Handled = true;
		}

		private void lblNgayQuay_SummaryGetResult(object sender, SummaryGetResultEventArgs e)
		{
			int LanQuayPhimID = (int)GetCurrentColumnValue("LanQuayPhimID");
			LanQuayPhimBO lanQuayPhimBO = this.lanQuayPhimBOCollection.GetBO(LanQuayPhimID);
			if (lanQuayPhimBO.NgayChup == null)
				e.Result = "";
			else
				e.Result = lanQuayPhimBO.NgayChup.Value.ToString("dd/MM/yyyy  HH:mm");
			e.Handled = true;
		}

		private void lblNgayGiao_SummaryGetResult(object sender, SummaryGetResultEventArgs e)
		{
			int LanQuayPhimID = (int)GetCurrentColumnValue("LanQuayPhimID");
			LanQuayPhimBO lanQuayPhimBO = this.lanQuayPhimBOCollection.GetBO(LanQuayPhimID);
			if (lanQuayPhimBO.NgayGiao == null)
				e.Result = "";
			else
				e.Result = lanQuayPhimBO.NgayGiao.Value.ToString("dd/MM/yyyy  HH:mm");
			e.Handled = true;
		}
	}
}
